package com.ruoyi.system.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysRole;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}/{orgId}/{orgName}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @PathVariable("orgId") Long orgId,@PathVariable("orgName") String orgName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/info/{username}/{orgId}")
    public R<LoginUser> getUserInfoNotOrg(@PathVariable("username") String username, @PathVariable("orgId") Long orgId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/userlist")
    public R<List<SysUser>> selectUserList(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/userRoleList")
    public R<List<SysUser>> selectUserRoleList(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/{userId}")
    public R<SysUser> selectUserById(@PathVariable("userId") Long userId);

    @GetMapping("/user/{userId}/{orgId}")
    public R<SysUser> selectUserByIdWithOrgId(@PathVariable("userId") Long userId, @PathVariable("orgId") Long orgId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/role/roleList")
    public R<List<SysRole>> selectRoleList(SysRole sysRole, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/role/{roleId}")
    public R<SysRole> selectRoleById(@PathVariable("roleId") Long roleId);

    @GetMapping("/user/getMySign")
    public R<String> getMySign(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/getMySign/{userId}")
    public R<String> getMySignByUserId(@PathVariable("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
